<?php
$model_product_category = new Model_ProductCat_ProductCat();
$model_product = new Model_Product_Product();
$data_product = $this->data;
$alias = $this->alias;
$dataCat = $model_product_category->getAll();
$count_first = 12;
$current_cat = $model_product_category->getItemAlias($alias);
?>
<script type="text/javascript">
$(document).ready(function(){
	var inc=<?php echo $count_first;?>;
    var order = 2;
	$(window).scroll(function() {
	    if ($('body').height()-190 <= ($(window).height() + $(window).scrollTop())) {
	    inc=inc+12;
	        var dataString = inc;
	        $.ajax({
	            type: "POST",
	            url: "<?php echo $this->baseUrl();?>/default/product/listcat/",
	            data: {'limit': dataString,'order':order,'alias':'<?php echo $alias; ?>'},
	            success: function(data) {
	                $('#products').html(data);
	            }
	        });
	    }
	});
	$('#click_next').click(function() {
    	inc=inc+3;
        var dataString = inc;
        $.ajax({
            type: "POST",
            url: "<?php echo $this->baseUrl();?>/default/product/listcat/",
            data: {'limit': dataString,'order':order,'alias':'<?php echo $alias; ?>'},
            success: function(data) {
                $('#products').html(data);
            }
        });
	});
	$('select').change(function() {
	    	inc=inc;
	        var dataString = inc;
	      	order =  $("select option:selected").val();
	        $.ajax({
	            type: "POST",
	            url: "<?php echo $this->baseUrl();?>/default/product/listcat/",
	            data: {'limit': dataString,'order':order,'alias':'<?php echo $alias; ?>'},
	            success: function(data) {
	                $('#products').html(data);
	            }
	        });
	});
	});
</script>
<div class="main product_page">
<div class="container">
<div class="menu_left">
<h3>Sản phẩm</h3>
<ul>
<?php
foreach ($dataCat as $item_cat)
{
	echo '<li><a href="'.$this->baseUrl().$model_product_category->getLinkById($item_cat['id']).'">'.$item_cat['name'].'</a></li>';
}
?>
</ul>
</div>
<!-- end menu_left-->
<div class="product">
<div class="top_product">
<form name="sortby"><label>Phân loại bởi</label> <select name="sort_by">
	<option value="2" selected="selected">Sản phẩm mới nhất</option>
	<option value="0">Giá tăng dần</option>
	<option value="1">Giá giảm dần</option>
</select></form>
<div class="soluong"><?php echo count($data_product);?> sản phẩm</div>
</div>
<!-- end top_product-->
<div class="clear"></div>
<ul id="products">
<?php
$i = 0;
foreach ($data_product as $item_pro)
{
	if($i<$count_first)
	{
		?>
	<li><a
		href="<?php echo $this->baseUrl().$model_product->getLinkById($item_pro['id']);?>"><img
		src="<?php echo $this->baseUrl();?>/public/images/products/thumbs/<?php echo $item_pro['image']?>"
		alt="" /></a>
	<p class="code"><?php echo $item_pro['code'];?></p>
	<p class="price"><?php echo number_format($item_pro['price']);?>
	VND</p>
	</li>
	<?php
	}
	$i++;
}
?>
</ul>
<div style="clear: both"></div>
<br />
<span id="click_next">Xem tiếp sản phẩm</span></div>
<!-- end product--></div>
<div class="clear"></div>
<?php $this->LoadBlock('BottomMenu');?></div>
<!-- end main-->
